package com.sun.mybatisplus.rabbitmq.consumer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @Auth: syh
 * @Date: 2021/10/22 15:42
 * @Email: 1014170249@qq.com
 * @Desc: 不在能知，而在能行
 * 消息的消费处理
 */
@Component
@Slf4j
public class SmsOrderConsumer {

    @RabbitListener(queues = {"sms_fanout.queue"})
    @RabbitHandler
    public void receiveMessage(String message) {
        log.info("接受到消息: 订单Id：{}", message);
    }


    @RabbitListener(queues = {"sms_direct.queue"})
    @RabbitHandler
    public void receiveMessageDirect(String message) {
        log.info("Direct模式接受到消息: 订单Id：{}", message);
    }


    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "duanxin_topic_queue",durable = "true",autoDelete = "false"),
            exchange = @Exchange(value = "topic_exchange",type = ExchangeTypes.TOPIC),
            key = "#.duanxin.#"
    ))
    public void receiveMessageTopic(String message) {
        log.info("-------------------------------------");
        log.info("Topic模式接受到消息: 订单Id：{}", message);
        log.info("-------------------------------------");
    }
}
